<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>获取QQ头像</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="Author" content="larry" />
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="Shortcut Icon" href="/favicon.ico" />
    <link rel="stylesheet" type="text/css" href="/static/admin/common/layui/css/layui.css" media="all">
    <link rel="stylesheet" type="text/css" href="/static/admin/backstage/css/base.css" media="all">
    <link rel="stylesheet" type="text/css" href="/static/admin/common/css/animate.css" media="all">
    <link rel="stylesheet" type="text/css" href="/static/admin/backstage/css/admin.css" media="all">
</head>
<body>
<div class="layui-fluid">
    <div class="larry-container larryms-admin">
        <div class="layui-row layui-col-space20">
            <div class="layui-col-xs12 animated fadeInRightBig">
                <section class="larry-panel">
                    <div class="larryms-page-header">
                        <span class="tit">获取QQ头像</span>
                    </div>
                    <div class="larryms-page-body">
                        <form class="layui-form" enctype="multipart/form-data">
                            <div class="layui-form-item">
                                <div class="layui-input-block">
                                    <img src="http://q.qlogo.cn/headimg_dl?dst_uin=505413&spec=100" alt="" id="img">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">QQ号</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="qq" value="" class="layui-input" placeholder="请输入QQ号码" id="qq">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">昵称</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="nickname" value="" class="layui-input" placeholder="昵称自动获取" readonly="readonly" id="nickname">
                                </div>
                            </div>
                        </form>
                    </div>
                </section>
            </div>
        </div>
    </div>
</div>
<!-- 加载js文件-->
<script type="text/javascript" src="/static/admin/common/layui/layui.js"></script>
<script type="text/javascript">
    layui.use(['form','jquery', 'layer'], function() {
        var form = layui.form;
        var $ = layui.$ //重点处
            , layer = layui.layer;
        $('body').on("blur", '#qq', function(event){
            $('#nickname').val('');
            var qq = $(this).val();
            var url = $(this).attr('ajax-url');
            $.ajax({
                url: url,
                data:{'qq':qq},
                datatype:'json',
                type:'post',
                success:function(mes){
                    if(!mes.code){
                        layer.msg("请填写正确qq", {icon: 2, anim: 6, time: 1000});
                        return false;
                    }if(mes.data == ''){
                        $('#nickname').val('游客');
                    } else {
                        $('#nickname').val(mes.data);
                    }
                    $("#img").attr("src",mes.image)
                }});
        });
    });
</script>
</body>
</html>